
********************************************************************************
*
* WHY GOVERNMENTS HAVE THEIR TROOPS TRAINED ABROAD:
* EVIDENCE FROM LATIN AMERICA
*
* By Adam Scharpf
*
* International Studies Quarterly
*
* June 2020
*
********************************************************************************
*
* Content:	Replication of results in manuscript and supporting information	
*
*			Steps:
*			1) Set working directory
*			2) Run do-file to replicate results in tables of manuscript and supporting information
*
********************************************************************************
*
* Packages: Before running this code, please make sure you have the following
*			.ado-files installed
*
*			- Parmest Package, Version 2
*					net install st0043_2.pkg
*
********************************************************************************


	version 15.1
	set more off

	clear all
  
 
 
********************************************************************************
*
* Setting working directory in macro
*
********************************************************************************

	*Insert path to folder containing dataset "data_allanalysis.dta" before running
	global path="..." //Example: "C:\Users\me\Desktop\Scharpf\"
	
 
 
********************************************************************************
*
* Producing log-file of results
*
********************************************************************************

	*Starting log file
	log using "$path\Scharpf_ISQ_resultslog", replace 

	
	
********************************************************************************
*
* Loading replication dataset
*
********************************************************************************

	*Loading replication dataset
	use "$path\data_allanalysis.dta"


	
********************************************************************************
*
* Descriptives
*
********************************************************************************
	
	****************************************************************************
	*Figure 2. Threats in Latin America, 1946-2004
	****************************************************************************	
	
	*Preserving data
	preserve	
	
	*Keeping relevant variables
	keep gwno year guerrillad strikesd riotsd demond dmidtowar 
	rename dmidtowar dmidtoward

	*Counting number of observations in data set
	gen totalobs=_N

	*Counting number of observations with respective threat type
	foreach var of varlist guerrillad strikesd riotsd demond dmidtowar   {
	egen total_`var'=total(`var')
	}
	
	*Calculating percentages for each threat type
	foreach var of varlist total_guerrillad total_strikesd total_riotsd total_demond total_dmidtowar  {
	gen perc`var'=(`var'/totalobs)*100
	}	
	
	*Keeping single values
	keep in 1
	keep perc*

	*Renaming variables
	ds 
	foreach v of var `r(varlist)' {
           local new = substr("`v'", 11,.)
           rename `v' `new'
	}
		
	*Reshaping data set
	gen help=1
	reshape long @d, i(help) string
	rename _j threat
	rename d perc
	
	*Figure 2
	gsort - perc
	gen yaxis=_n*.5
	
	#delimit ;
	twoway  dropline perc yaxis,
		horizontal
		msymbol(o) msize(*1.3) mfcolor(black) mlcolor(black) mlwidth(*1.1) // mlalign(center)
		lcolor(black) lwidth(*1)
		ylabel(
			.5 "Demonstrations" 
			1 "Riots"
			1.5 "Conventional wars" 
			2 "Guerrilla attacks" 
			2.5 "Strikes" 
			, labsize(3) labgap(*5) noticks angle(horizontal) nogrid)
		xsize(1)
		ysize(1)
		yscale(range(.25 2.75) noline)	
		xscale(range(0 50))
		xlabel(0(10)50, labsize(3) nogrid) //grid glwidth(*.5) glpattern(solid) glcolor(gs12) nogmin nogmax
		xtick(0(2)50, tlength(*.5))
		ytitle("")
		xtitle("Percentages", size(3))
		plotregion(lcolor(white) m(zero))
		graphregion(color(white) lcolor(white) lalign(outside))
		legend(off)
		;
	#delimit cr	
	graph export "$path\figure2.pdf", as(pdf) replace
	
	*Restoring data
	restore	
	

	****************************************************************************
	*Figure 3. Distribution of the dependent variable
	****************************************************************************	
	
	*Generating variables for hisogram incl. break in y-axis
	egen freq=count(1), by(soaGEN)
	gen freq2=0 if freq!=.
	tab freq if soaGEN==0
	replace freq=100 if freq==723 & soaGEN==0
	gen liney=90 in 1/3
	gen linex=_n-2 in 1/3
	gen rcapx=0 in 1
	gen rcapy1=91.19 in 1
	gen rcapy2=88.81 in 1

	*Figure 3
	#delimit ;
	twoway 
		(rbar freq freq2 soaGEN, color(black) fintensity(100))
		(rcap rcapy1 rcapy2 rcapx, 	lwidth(0.25) lcolor(black))
		(line liney linex, lwidth(1.5) lcolor(white))
		,
		yscale(range(0 100) noextend)
		xscale(range(0 800) noextend titlegap(*+10))	
		ylabel(0(10)80 100 "723", angle(horizontal) nogrid) 
		xlabel(0(100)800, nogrid)
		xtick(0(50)800, tlength(*.5))
		ytitle("Frequency")	
		xtitle("Number of SOA courses attended (in country-year)")
		legend(off) 
		plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
		;
	#delimit cr
	graph export "$path\figure3.pdf", as(pdf) replace	

	
	****************************************************************************
	*Figure 4. Distribution of course start dates
	****************************************************************************		
	
	*Preserve data
	preserve
	
	*Loading data for Figure 4
	use "$path\data_figure4.dta", clear
	
	*Figure 4	
	#delimit ;
	hist month_num if soaGEN==1, 
		 disc
		 width(.5)
		 ysize(1)
		 xsize(1.25)		 
		 fcolor(gs12) lwidth(none)
		 yscale(range(0 .4) noextend titlegap(+2))
		 xscale(range(1 12) noextend titlegap(+2))
		 ylabel(, angle(horizontal) nogrid nogmin)
		 xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul" 8 "Aug" 9 "Sep" 10 "Oct" 11 "Nov" 12 "Dec")
		 xtitle("Month")
		 ytitle("Density")
		 plotregion(lcolor(white)) 
		graphregion(color(white) lcolor(white) lalign(outside))	
	;
	#delimit cr
	graph export "$path\figure4.pdf", as(pdf) replace	
	
	*Restoring data
	restore
	

	
********************************************************************************
*
* Empirical results
*
********************************************************************************


	****************************************************************************
	*Table 1. Results for course attendance at School of the Americas, 1946–2004
	****************************************************************************

	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(lfpsimusa) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
		
	****************************************************************************
	*Figure 5. Marginal effect of foreign policy similarity on the decision to have troopstrained abroad
	****************************************************************************	
	
	*Identifying obeservations in Model 3, Table 1
	#delimit ;
	quiet zinb soaGEN 
		i.lguerrillad i.lstrikesd i.lriotsd i.ldemond i.ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa i.carter i.reagan1 i.postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
			;
	#delimit cr

	*Generating rug elements
	gen modelobs=1 if e(sample) & lfpsimusa<=5
	gen sym="|"
	gen yaxis=-.13


	*Running Model 3, Table 1
	#delimit ;
	zinb soaGEN 
		i.lguerrillad i.lstrikesd i.lriotsd i.ldemond i.ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa i.carter i.reagan1 i.postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
		
		//Calculating marginal effects
		margins, 
				at((asobserved) _all lfpsimusa=(0(.1)5))
				expression(1-predict(pr)) post;
			
		//Figure 5
		marginsplot,
				recastci(rspike)
				ciopts(lcolor(black) lwidth(*1.5)) 
				plotopts(mcolor(black) msize(*.8) lcolor(black))
				ysize(1)
				xsize(1.25)
				yscale(range(0 1) noextend titlegap(+2))
				xscale(range(0 5) noextend titlegap(+2))
				ylabel(0(.2)1, angle(horizontal) nogrid)
				xlabel(0(1)5)
				ytitle("Predicted probability (y=1) of sending troops to SOA", color(black))
				xtitle("Similarity with US foreign policy")
				title("")
				legend(off)
				plotregion(lcolor(white)) 
				graphregion(color(white) lcolor(white) lalign(outside))	
				addplot(scatter yaxis lfpsimusa if modelobs==1, mlabposition(0) ms(none) mlabel(sym) mlabcolor(black))
				;
	#delimit cr
	graph export "$path\figure5.pdf", as(pdf) replace	
		

	****************************************************************************
	*Figure 6. Marginal effects of threat types on the amount of foreign training demanded
	****************************************************************************

	*Running Model 3, Table 1

	#delimit ;
	//Saving model to local
	local model3="zinb soaGEN 
	i.lguerrillad i.lstrikesd i.lriotsd i.ldemond i.ldmidtoward llntroopqual llninflation
	,inflate(lfpsimusa llntradedepusa i.carter i.reagan1 i.postcoldwar llnmilexppc) 
	zip vce(cluster gwno)";

	//Running model
	quiet `model3';
	
	//Calculating and exporting marginal effects (95% CIs)
	margins, dydx(lguerrillad lstrikesd lriotsd ldemond ldmidtoward) 
			 at((asobserved) _all) 
			 level(95) 
			 post;
	parmest, saving("$path\figure6_ci95.dta", replace) format(estimate min95 max95);
	
		//Running model again
	quiet `model3';
	
	//Calculating and exporting marginal effects (90% CIs)
	margins, dydx(lguerrillad lstrikesd lriotsd ldemond ldmidtoward) 
			 at((asobserved) _all) 
			 level(90)
			 post;
	parmest, saving("$path\figure6_ci90.dta", replace) level(90);
	#delimit cr	
	
	*Preserving data
	preserve
	
	*Merging both output files
	use "$path\figure6_ci95.dta", clear
	merge 1:1 parm using "$path\figure6_ci90.dta", keepusing(max90 min90)
	drop _merge
	keep if regexm(parm,"^1")
	gen varname=regexs(2) if regexm(parm,"(^[0-9][.][l])([a-z]+)([d])")
	
	*Assigning values on y-axis
	gen yvar=5 if varname=="guerrilla"
	replace yvar=4 if varname=="strikes"
	replace yvar=3 if varname=="demon"
	replace yvar=2 if varname=="riots"
	replace yvar=1 if varname=="dmidtowar"
	
	*Figure 6
	#delimit ;		
	twoway (rspike min95 max95 yvar, //95% CI
					 horizontal lcolor(gs5) lwidth(thin)
			)
		   (rspike min90 max90 yvar, //90% CI
					 horizontal lcolor(black) lwidth(*2.25)
		    )
		   (scatter yvar estimate,	
					 msymbol(o) msize(*1.25) mlwidth(*1) mcolor(black) mfcolor(black) mlalign(center))
					,
					ysize(1)
					xsize(1.25) 
					yscale(range(.5 5.5) noline )
					xscale(range(-40 140) noextend titlegap(*+10)) 
					ylabel(1 "Conventional war" 2 "Riot" 3 "Demonstration" 4 "Strike" 5 "Guerrilla attack", 
							nogrid labsize(small) angle(0))
					xlabel(-40(20)120, labsize(small)) 
					ytitle("")
					xtitle("Change in expected number of courses attended", size(small))
					legend(order(3 "Marginal effect" 1 "95% CI" 2 "90% CI")  position(5) ring(0) bmargin(-1) col(1) row(5) 
							size(small) keygap(*0.5) symxsize(*0.5) symysize(*0.5) region(color(white)))
					xline(0,lpattern(shortdash) lwidth(thin) lcolor(black))
					graphregion(color(white) lcolor(white) lalign(outside)); 
	#delimit cr	
	graph export "$path\figure6.pdf", as(pdf) replace

	*Restoring data
	restore

	
	****************************************************************************
	*Figure 7. Regime change and training patterns
	****************************************************************************	
	
	*Preserving data
	preserve
	
	*Loading data for Figure 7
	use "$path\data_figure7.dta", clear	
	
	*Figure 7
	#delimit ;
	twoway (lpoly soaperc prewin if prewin!=., 
							bwidth(1) kernel(gaussian)
							lpattern(shortdash) lcolor(black) lwidth(*1.5))
		   (lpoly soaperc postwin if postwin!=. & postwin>=1, 
							bwidth(1) kernel(gaussian)
							lpattern(solid) lcolor(black) lwidth(*1.5))
		   ,
		   xline(0, lcolor(gs12) lwidth(*5))
		   yscale(range(0 20) noextend titlegap(*+10))
		   xscale(range(-12 12) noextend titlegap(*+10)) 
		   ylabel(0(5)20, angle(0) nogrid )			
		   xlabel(-12(6)12)
		   xticks(-12(1)12, tlength(*.5))
		   ytitle("Number of SOA courses in % (smoothed)", size(*1))
		   xtitle("Months", size(*1))
		   legend(off)
		   graphregion(color(white) lcolor(white) lalign(outside))	
		   text(20 -6 "Democracy", place(c))
		   text(20 6 "Military regime", place(c))
	;
	#delimit cr	
	graph export "$path\figure7.pdf", as(pdf) replace 	
	
	*Restoring data
	restore
		
	
	****************************************************************************
	*Figure 8. Leader change in Brazil and SOA attendance (monthly level)
	****************************************************************************	

	*Preserving data
	preserve
	
	*Loading data for Figure 8
	use "$path\data_figure8.dta", clear	
	
	*Figure 8
	#delimit ;
	twoway (scatter soa_d time,
							msize(*.85) mcolor(black%30) mlwidth(none) mlalign(outside))
		   (rspike llow lhigh time,
							lcolor(black)  
							lwidth(*.75)
							lpattern(shortdash)
							)								
		   (lpoly soa_d time, 
							lpattern(solid) lcolor(black) lwidth(*1.5)  
							bwidth(1) kernel(gaussian))			
		   , 
		   ttext(1.1 19 "Castelo Branco", placement(c) size(*1) color(black))
		   ttext(1.1 51 "Costa e Silva", placement(c) size(*1) color(black))			   
		   ttext(1.1 92 "Médici", placement(c) size(*1) color(black))	
		   ttext(1.1 149 "Geisel", placement(c) size(*1) color(black))
		   ttext(1.1 216 "Figueiredo", placement(c) size(*1) color(black))
		   xsize(2.5)
		   ysize(1)		
		   yscale(range(0 1) noextend titlegap(*+5))
		   xscale(range() noextend titlegap(*+10)) 
		   ylabel(0 "No" 1 "Yes", angle(0) nogrid  labsize(*1.1))			
		   xlabel(5.5 "1964" 16 "1965" 28 "1966" 40 "1967" 52 "1968" 64 "1969" 76 "1970" 
				  88 "1971" 100 "1972" 112 "1973" 124 "1974" 136 "1975" 148 "1976"
				  160 "1977" 172 "1978" 184 "1979" 196 "1980" 208 "1981" 220 "1982" 
				  232 "1983" 244 "1984" 
		   , noticks labgap(*2.75) labsize(*1.1))	 
		   xticks(1 10(12)250)
		   ytitle("Sending troops to SOA", size(*1.1))
		   xtitle("", size(*.7))
		   legend(off)
		   graphregion(color(white) lcolor(white) lalign(outside))		   
	;
	#delimit cr	
	graph export "$path\figure8.pdf", as(pdf) replace
	
	*Restoring data	
	restore 
	
	
	****************************************************************************
	*Figure 9. Foreign training and military effectiveness
	****************************************************************************		
	
	*Calculating and exporting marginal effects
	#delimit ;
		
	//Saving model 6 to local
	local modelm6="logit coin
	llnsoaCOIN llnsoaNOCOINWARS
	i.lguerrillad i.lstrikesd i.lriotsd i.ldemond i.ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa i.carter i.reagan1 i.postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)";

	//Running model 6
	quiet `modelm6';	
	
	*Assessing empirical range
	sum llnsoaCOIN llnsoaNOCOINWARS if e(sample);
	
	//Re-running model 6
	quiet `modelm6';
	
	//Calculating marginal effects for COIN warfare
	margins, 
		at((asobserved) _all llnsoaNOCOINWARS=0 llnsoaCOIN=(0(.1)6))
		expression(predict(pr)) 
		post;
	parmest, saving("$path\figure9_coin.dta", replace) level(90 95) idstr("llnsoaCOIN");	
	
	//Re-running model 6
	quiet `modelm6';
	
	//Calculating marginal effects for non-COIN warfare
	margins, 
		at((asobserved) _all llnsoaCOIN=0 llnsoaNOCOINWARS=(0(.1)6))
		expression(predict(pr)) 
		post;
	parmest, saving("$path\figure9_noncoin.dta", replace) level(90 95) idstr("llnsoaNOCOINWARS");			
	
	#delimit cr	
	
	*Preserving data
	preserve
	
	*Appending exported datasets with marginal effects 
	clear
	use "$path\figure9_coin.dta"
	append using "$path\figure9_noncoin.dta"

	*Reshaping data
	gen id="_coin" if regexm(idstr, "soaCOIN")
	replace id="_nocoin" if regexm(idstr, "soaNOCOINWARS") & id==""
	
	gen panel=regexs(0) if regexm(parm,"^[0-9]+")
	destring panel, replace
	keep estimate min* max* panel id
	reshape wide estimate min* max*, i(panel) j(id) string
	
	*Generating x-axis
	gen xaxis=(_n-1)*0.1 in 1/61
	gen xaxis_coin=xaxis-0.02
	gen xaxis_nocoin=xaxis+0.02
	
	*Figure 9	
	#delimit ;		
	twoway line estimate_nocoin xaxis_nocoin,
					 lcolor(gs8) lwidth(*.9)				 				 
		  || rspike min95_nocoin max95_nocoin xaxis_nocoin,
					 lcolor(gs8) lwidth(*1.15)
		  || scatter estimate_nocoin xaxis_nocoin,
					 msymbol(o) msize(*.65) mfcolor(white) mlcolor(gs8) mlwidth(*.8) mlalign(outside)				 
		  || line estimate_coin xaxis_coin,
					 lcolor(black) lwidth(*.9)						 
		  || rspike min95_coin max95_coin xaxis_coin,
					 lcolor(black) lwidth(*1.15)				 
		  || scatter estimate_coin xaxis_coin,
					 mcolor(black) msize(*.65) lcolor(black)				
				 xsize(1.2) ysize(1) 
				 xscale(range() noextend titlegap(+2))
				 yscale(range() noextend titlegap(+2))
 	             ylabel( , valuelabel nogrid angle(0) labsize(*.85)) 
				 xlabel(0(1)6, angle(horizontal) nogrid labsize(*.85))
				 xtitle("Number of SOA courses attended (logged)", size(*.85))
				 ytitle("Predicted probability (y=1) of full insurgent war", size(*.85))
				 legend(order(
						3 "Conventional warfare courses"				 
						6 "Counterinsurgency courses" 
						)					
					col(1)
					size(*.75) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(color(white))
					position(7) ring(0) bmargin(2 0 5 0)
					)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
				 ; 
	#delimit cr		
	graph export "$path\figure9.pdf", as(pdf) replace		
	
	*Restoring data
	restore
	
	
	****************************************************************************
	*Figure 10. Recipients of US-sponsored military training, 2017
	****************************************************************************	

	*See Do-File "replication_figure10.do"	
	


********************************************************************************
*
* Results in Supporting Information
*
********************************************************************************

********************************************************************************
*SI.1    Summary statistics
********************************************************************************

	****************************************************************************
	*Table SI.1.1. Summary statistics
	****************************************************************************

	#delimit ;
	sum
		soaGEN soaENLIST soaOFFIC 
		lfpsimusa 
		llnustroops 
		mildict		
		lguerrillad 
		lguerrilla
		lcoin lbkirregular 
		lstrikesd 
		lstrikes 
		ldemond
		ldemon
		lriotsd 
		lriots
		ldmidtoward
		lmidtoward 		
		llntradedepusa 
		carter reagan1 llnmilexppc postcoldwar
		llntroopqual llninflation
		coindoc 
		soausa 
		actmilcabshare
		lactmilcabshare	
		yrscoup 
		yrscoup2 
		yrscoup3
		ldemoc
		;
	#delimit cr	
	
	
	****************************************************************************
	*Table SI.1.2. Summary statistics on suppressing insurgent wars
	****************************************************************************	

	#delimit ;
	sum	
		coin
		bkirregular
		llnsoaGEN
		llnsoaWARS
		llnsoaNOCOINWARS
		llnsoaCOIN
		lSOAratio_coingen
		lguerrillad 
		lstrikesd 
		ldemond
		lriotsd 
		ldmidtoward
		lfpsimusa
		llntradedepusa 
		carter 
		reagan1  
		postcoldwar
		llntroopqual 
		llninflation				
		ctime 
		ctime2 
		ctime3
		irrtime 
		irrtime2 
		irrtime3	
		;
	#delimit cr		

	
	****************************************************************************
	*Table SI.1.3. Summary statistics on course selection.
	****************************************************************************	
	
	#delimit ;
	sum		
		soaNOCOINWARS 
		soaCOIN		
		lfpsimusa 
		lguerrilladout 
		lbkirregular 
		lstrikesd 
		lriotsd 
		ldemond 
		ldmidtoward 
		llntradedepusa 
		carter reagan1 llnmilexppc postcoldwar
		llntroopqual 
		llninflation	
		;
	#delimit cr	
	
	
********************************************************************************
*SI.2    Additional case information
********************************************************************************	
	
	****************************************************************************
	*Figure SI.2.1. Training at the School of the Americas, 1946-2004
	****************************************************************************	
	
	*Preserving dataset
	preserve

	*Keeping relevant variables
	keep gwno countryname year soaGEN

	*Generating values on x-axis
	bys gwno (year): gen yearstart=year if soaGEN>0 & soaGEN!=.
	bys gwno (year): gen yearend=year+1 if soaGEN>0 & soaGEN!=.
	
	*Generating and labeling y-axis variable
	sort countryname year
	egen yhelp=group(countryname)
	quiet sum yhelp
	gen yaxis=(r(max)+1)-yhelp
	labmask yaxis, values(countryname)
		
	*Figure SI.2.1
	#delimit ;
	twoway rbar yearstart yearend yaxis,
		fcolor(gs2) lcolor(white) lalign(center)
		horizontal
		xsize(1.25)
		ysize(1)
		yscale(range(0 33) noextend)	
		xscale(range(1945 2005) noextend)
		ylabel(1(1)33, valuelabel labsize(*.75) labgap(*2) angle(horizontal) nogrid)
		xlabel(1946 1955(10) 1995 2004, labsize(*.75) nogrid)
		xtick(1950(10)2000, labsize(*.5))
		ytitle("")
		xtitle("", size(3))
		plotregion(lcolor(white) m(zero))
		graphregion(color(white) lcolor(white) lalign(outside))
		legend(off)
		;
	#delimit cr
	graph export "$path\figureSI21.pdf", as(pdf) replace
	
	*Restoring dataset
	restore	
	
	
	****************************************************************************
	*Figure SI.2.2. Course attendance at the School of the Americas, 1946-2004
	****************************************************************************	

	*See Do-File "replication_figuresi22.do"	
	
	
********************************************************************************
*SI.3    Descriptive evidence
********************************************************************************		
		
	****************************************************************************
	*Figure SI.3.1. Diplomatic and military logics of SOA training
	****************************************************************************		
	
	*Preserving data
	preserve

	*Identifying countries with and without SOA training
	gen soadum=0 if soaGEN==0
	replace soadum=1 if soaGEN>=1 & soaGEN!=.	
	
	*Generating count variables for guerrilla attacks
	bysort soadum year: egen guerobs=total(guerrillad)
	bysort soadum year: gen allobs=_N

	*Collapsing data
	collapse (mean) fpsimusa (first) guerobs allobs, by(soadum year)

	*Calculating proportion of countries with guerrilla attacks
	gen guerrprop=(guerobs/allobs)*100

	*Reshaping data from long to wide for plotting
	reshape wide fpsimusa guerobs guerrprop allobs, i(year) j(soadum)

	*Plotting foreign policy preferences
	#delimit ;
	twoway (line fpsimusa0 year, lcolor(gs10) lpattern(shortdash) lwidth(*1.5))
		   (line fpsimusa1 year,  lcolor(black) lpattern(solid) lwidth(*1.5))
			,
			ysize(1)
			xsize(1.25)
			yscale(range(1 5) noextend titlegap(+2))
			xscale(off)		   
			ylabel(1(1)5, angle(horizontal) nogrid)
			xlabel(1950(10)2000)
			xticks(1945(1)2004,tlength(*.5))		
			ytitle("Average similarity with US foreign policy")
			xtitle("")
			legend(
				order(2 "Countries using training" 1 "Countries not using training")
				size(*1) keygap(*0.5) symxsize(*.5) symysize(*1) region(lcolor(white))
				cols(1)
				position(2) ring(0) bmargin(0)
			
			)
			title("(a)", color(black) size(*.75))
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))		
			name(policy, replace)
			;
	#delimit cr

	*Plotting guerrilla activity over time
	gen nosoayear=year-0.15
	gen soayear=year+0.15

	#delimit ;
	twoway (spike guerrprop0 nosoayear, lcolor(gs10) lwidth(*2) lpattern(shortdash))
		   (spike guerrprop1 soayear, lcolor(black) lwidth(*2) lpattern(solid))
		   ,		
			ysize(1)
			xsize(1.25)
			yscale(range(10 70) noextend titlegap(+2))
			xscale(range(1945 2004) noextend)		   
			ylabel(0(10)70, angle(horizontal) nogrid)
			xlabel(1950(10)2000)
			xticks(1945(1)2004,tlength(*.5))
			ytitle("Percent with guerrilla activity" "")
			xtitle("")
			legend(
				off
			)
			title("(b)", color(black) size(*.75) bcolor(none) fcolor(none))
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			name(guerr, replace)
			;
	#delimit cr

	*Figure SI.3.1
	#delimit ;
	graph combine policy guerr, 
			col(1) imargin(b=4.25 t=1)
			graphregion(color(white) lcolor(white) lalign(outside))
			;
	#delimit cr
	graph export "$path\figureSI31.pdf", as(pdf) replace

	*Restoring data 
	restore		
	
	
********************************************************************************
*SI.4    Probing the mechanism
********************************************************************************		
	
	****************************************************************************
	*Figure SI.4.1. Start of insurgent wars and SOA training
	****************************************************************************	
	
	*Preserving data
	preserve
	
	*Loading data for Figure SI.4.1
	use "$path\data_figuresi41.dta", clear
		
	*Figure SI.4.1	
	#delimit ;
	twoway (lpoly soaperc prewin if prewin!=. & winid>166, 
					bwidth(4) kernel(gaussian)
					lpattern(shortdash) lcolor(black) lwidth(*1.5))
		   (lpoly soaperc postwin if postwin!=. & postwin>=1 & winid>166, 
					bwidth(4) kernel(gaussian)
					lpattern(solid) lcolor(black) lwidth(*1.5))
		   ,
		   xline(0, lcolor(gs12) lwidth(*5))
		   yscale(range(0 10) noextend titlegap(*+10))
		   xscale(range(-12 24) noextend titlegap(*+10)) 
		   ylabel(0(2)10, angle(0) nogrid )			
		   xlabel(-12(6)24)
		   xticks(-12(1)24, tlength(*.5))
		   ytitle("Number of SOA courses in % (smoothed)", size(*1))
		   xtitle("Months", size(*1))
		   legend(off)
		   graphregion(color(white) lcolor(white) lalign(outside))	
		   text(10 -6 "Peace", place(c))
		   text(10 12 "Insurgency", place(c))
	;
	#delimit cr		
	graph export "$path\figureSI41.pdf", as(pdf) replace 	

	*Restoring data 
	restore		
		
	
	****************************************************************************
	*Table SI.4.1. Reversing diplomatic and military logic
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward lfpsimusa
		,inflate(lfpsimusa lguerrillad lstrikesd lriotsd ldemond ldmidtoward) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward lfpsimusa llntroopqual llninflation
		,inflate(lfpsimusa lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	
	****************************************************************************
	*Table SI.4.2. Structural changes in the School of the Americas
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation coindoc
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc coindoc) 
		zip vce(cluster gwno);
	#delimit cr	
	
	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation soausa
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc soausa) 
		zip vce(cluster gwno);
	#delimit cr
 	
	
********************************************************************************
*SI.5    Effects of training at the School of the Americas
********************************************************************************
	
	****************************************************************************
	*Table SI.5.1. Training content and occurrence of insurgent war (Lyall & Wilson)
	****************************************************************************	
	
	*Model 1
	#delimit ;
	logit coin
	llnsoaGEN
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)
	;
	#delimit cr	
	
	*Model 2
	#delimit ;
	logit coin
	llnsoaWARS
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)
	;
	#delimit cr	
	
	*Model 3
	#delimit ;
	logit coin
	llnsoaCOIN llnsoaNOCOINWARS
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)
	;
	#delimit cr		
	
	*Model 4
	#delimit ;
	logit coin
	lSOAratio_coingen
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)
	;
	#delimit cr	

	
	****************************************************************************
	*Table SI.5.2. Training content and occurrence of insurgent war (Kalyvas & Balcells)
	****************************************************************************

	*Model 1
	#delimit ;
	logit bkirregular
	llnsoaGEN
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	irrtime irrtime2 irrtime3
	,vce(cluster gwno)
	;
	#delimit cr	
	
	*Model 2
	#delimit ;
	logit bkirregular
	llnsoaWARS
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	irrtime irrtime2 irrtime3
	,vce(cluster gwno)
	;
	#delimit cr
	
	*Model 3
	#delimit ;
	logit bkirregular
	llnsoaCOIN llnsoaNOCOINWARS
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	irrtime irrtime2 irrtime3
	,vce(cluster gwno)
	;
	#delimit cr			
	
	*Model 4
	#delimit ;
	logit bkirregular
	lSOAratio_coingen
	lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa carter reagan1 postcoldwar
	irrtime irrtime2 irrtime3
	,vce(cluster gwno)
	;
	#delimit cr	

	
	****************************************************************************
	*Figure SI.5.1. Course type and suppression of insurgent wars
	****************************************************************************

	*Preserving data
	preserve

	*Calculating and exporting marginal effects
	#delimit ;
		
	//Saving model to local
	local modelm14="logit coin
	lSOAratio_coingen
	i.lguerrillad i.lstrikesd i.lriotsd i.ldemond i.ldmidtoward llntroopqual llninflation lfpsimusa llntradedepusa i.carter i.reagan1 i.postcoldwar
	ctime ctime2 ctime3
	,vce(cluster gwno)";

	//Identifying obeservations in model
	
	//Running model
	quiet `modelm14';	
	
	//Preparing rug elements
	gen modelobs2=1 if e(sample) & lSOAratio_coingen<=1;
	gen sym2="|" ;
	gen yaxis2=0.05 ;	
		
	//Running model
	quiet `modelm14';	
	
	//Calculating marginal effects
	margins, 
			at((asobserved) _all lSOAratio_coingen=(0(.02)1))
			predict(pr) post;
		
	//Figure SI.5.1
	marginsplot,
			recastci(rspike)
			ciopts(lcolor(black) lwidth(*1.5)) 
			plotopts(mcolor(black) msize(*.8) lcolor(black))
			ysize(1)
			xsize(1.25)
			yscale(range(.05 .2) noextend titlegap(+2))
			xscale(range(0 1) noextend titlegap(+2))
			ylabel(.05(.05).2, angle(horizontal) nogrid)
			xlabel(0(.1)1)
			ytitle("Predicted probability (y=1) of full insurgent war", color(black))
			xtitle("Fraction of counterinsurgency courses")
			title("")
			legend(off)
			plotregion(lcolor(white)) 
			graphregion(color(white) lcolor(white) lalign(outside))	
			addplot(scatter yaxis2 lSOAratio_coingen if modelobs2==1, mlabposition(0) ms(none) mlabel(sym2) mlabcolor(black))
			;
	#delimit cr	
	graph export "$path\figureSI51.pdf", as(pdf) replace		
	
	*Restoring data
	restore	

	
	****************************************************************************
	*Table SI.5.3. Full insurgent wars (Kalyvas & Balcells), 1946-2004
	****************************************************************************	
	
	*Preserving data
	preserve
	
	*Loading data for Table SI.5.3
	use "$path\data_tableSI53.dta", clear
	
	*Table SI.5.3
	list countryname insurgents yrst yrend
		
	*Restoring data
	restore
		
	
	****************************************************************************
	*Table SI.5.4. Threat escalation and course types
	****************************************************************************	

	*Model 1
	#delimit ;
	zinb soaCOIN 
		lguerrilladout lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc)   
		zip vce(cluster gwno);
	#delimit cr	
	
	*Model 2
	#delimit ;
	zinb soaCOIN 
		lbkirregular lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc)
		zip vce(cluster gwno);
	#delimit cr	
		
	*Model 3
	#delimit ;
	zinb soaCOIN 
		lguerrilladout lbkirregular lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc)
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 4
	#delimit ;
	zinb soaNOCOINWARS 
		lguerrilladout lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr	
	
	*Model 5
	#delimit ;
	zinb soaNOCOINWARS 
		lbkirregular lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr		
	
	*Model 6
	#delimit ;
	zinb soaNOCOINWARS 
		lguerrilladout lbkirregular lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr	

	
********************************************************************************
*SI.6    Robustness checks
********************************************************************************	

	****************************************************************************
	*Table SI.6.1. Distinguishing student types
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaENLIST 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr	
	
	*Model 2
	#delimit ;
	zinb soaOFFIC
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr

	
	****************************************************************************
	*Table SI.6.2. Different measures of agreement with US foreign policy
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(llnustroops) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(llnustroops llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(mildict) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 4
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(mildict llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	
	****************************************************************************
	*Table SI.6.3. Different measures of insurgent threat
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lcoin lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(lfpsimusa) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 2
	#delimit ;
	zinb soaGEN 
		lcoin lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr	
	
	*Model 3
	#delimit ;
	zinb soaGEN 
		lbkirregular lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(lfpsimusa) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 4
	#delimit ;
	zinb soaGEN 
		lbkirregular lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	
	****************************************************************************
	*Table SI.6.4. Count measures of threat variables
	****************************************************************************	

	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward
		,inflate(lfpsimusa) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	
	****************************************************************************
	*Table SI.6.5. Controlling for military influence over politics
	****************************************************************************	

	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward actmilcabshare
		,inflate(lfpsimusa actmilcabshare) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward lactmilcabshare
		,inflate(lfpsimusa lactmilcabshare) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation actmilcabshare
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc actmilcabshare) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 4
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation lactmilcabshare
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc lactmilcabshare) 
		zip vce(cluster gwno);
	#delimit cr
	
	
	****************************************************************************
	*Table SI.6.6. Controlling for democratic regimes
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward ldemoc
		,inflate(lfpsimusa ldemoc) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward ldemoc
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc ldemoc) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrilla lstrikes lriots ldemon lmidtoward llntroopqual llninflation ldemoc
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc ldemoc) 
		zip vce(cluster gwno);
	#delimit cr
		
	
	****************************************************************************
	*Table SI.6.7. Controlling for coup-proofing
	****************************************************************************	
	
	*Model 1
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward 
		,inflate(lfpsimusa yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 2
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 3
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 4
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward yrscoup yrscoup2 yrscoup3 
		,inflate(lfpsimusa yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 5
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward yrscoup yrscoup2 yrscoup3
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr

	*Model 6
	#delimit ;
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation yrscoup yrscoup2 yrscoup3
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc yrscoup yrscoup2 yrscoup3) 
		zip vce(cluster gwno);
	#delimit cr
	
		
	****************************************************************************
	*Table SI.6.8. Excluded observations in outlier test
	****************************************************************************	
	
	*Preserving data
	preserve

	*Calculating number of excluded observations in each model run
	
	*Running Model 3, Table 1
	#delimit ;
	quiet
	zinb soaGEN 
		lguerrillad lstrikesd lriotsd ldemond ldmidtoward llntroopqual llninflation
		,inflate(lfpsimusa llntradedepusa carter reagan1 postcoldwar llnmilexppc) 
		zip vce(cluster gwno);
	#delimit cr
	
	*Creating identifier for obs in analysis	
	gen obsjack=1 if e(sample) 
	keep if obsjack==1
	egen totobs=total(obsjack)
	
	*Collapsing data for information on amount of excluded observations
	collapse (first) countryname totobs (count) exclobsnum=obsjack, by(gwno)
	
	*Preparing data for export
	sort countryname
	gen exclobsperc=(exclobsnum/totobs)*100
	replace exclobsperc=round(exclobsperc,0.01)	//Share of excluded obs (in %)
	format exclobsperc %9.2f
	gen run=_n
	sum exclobsnum
	drop gwno totobs
	order run countryname	
	
	*Displaying information in table
	list
	
	*Restoring data
	restore
	
	
	****************************************************************************
	*Figure SI.6.1. Outlier test with country-wise exclusion
	****************************************************************************	
	
	*Preserving data
	preserve
	
	*Loading jackknife dataset for Figure SI.6.1
	use "$path\data_figureSI61.dta", clear

	*Figure SI.6.1		
	#delimit ;		
	twoway rspike min95 max95 yaxis, //95% CI
					 horizontal lcolor(gs5) lwidth(*1)	
		  || rspike min90 max90 yaxis, //90% CI
					 horizontal lcolor(black) lwidth(*2.2)
		  || scatter yaxis estimate, //Mean			  
				 msymbol(o) msize(*1) mlwidth(*1) mcolor(black) mfcolor(black) mlalign(center)
		  || rspike min95 max95 yaxis if id==., //95% CI
					 horizontal lcolor(gs5) lwidth(*1)	
		  || rspike min90 max90 yaxis if id==., //90% CI
					 horizontal lcolor(blue) lwidth(*2.2)
		  || scatter yaxis estimate if id==., //Mean			  
				 msymbol(o) msize(*1) mlwidth(*1) mcolor(blue) mfcolor(blue) mlalign(center)				 
				 by(varid, col(2) 
					legend(at(7) pos(3) bplacement(3))
					note("") graphregion(color(white) lcolor(white) lalign(outside))
					ixaxes
				 ) 
				 xsize(1.5) ysize(3) 
				 xscale(range() noextend titlegap(*40))
				 yscale(range(2 56) noextend  titlegap(*-25))
 	             ylabel(2(2)56 60, valuelabel nogrid angle(0) labsize(*.7)) 
				 xlabel(, angle(horizontal) nogrid labsize(*.7))
				 xticks()
				 xline(0,lpattern(shortdash) lwidth(thin) lcolor(black))
				 subtitle(, size(*1) lcolor(black))
				 xtitle(" ", size(*.55))
				 ytitle("Country excluded from analysis", size(*.55))
				 subtitle(, size(*.8) box bexpand margin(t=1.25) fcolor(gs14) lcolor(black) lalign(center))
				 scheme(s2mono)
				 legend(order(
						3 "Coefficent estimate"
						1 "95% CI" 
						2 "90% CI"
						)					
					col(1)
					size(*.7) 			
					keygap(*0.5) 
					symxsize(*0.35) 
					symysize(*0.5) 
					region(color(white))
					)
				 ; 
	#delimit cr		
	graph export "$path\figureSI61.pdf", as(pdf) replace	
			
	*Restoring data
	restore
	
	
********************************************************************************	
*	
********************************************************************************		
	
	*Closing graph windows
	graph close _all 
	
	*Clearing data
	clear all
	
	*End recording log file
	log close	
	
	